package org.ccay.async.conduit;

import java.util.Properties;

import kafka.javaapi.producer.Producer;
import kafka.producer.ProducerConfig;

/**
 * kafka producer factory
 */
public class KafkaProducerFactory {

	private Properties producerConfig;
	
	private static Producer<String, Object> producer;
	
	private ProducerConfig config;
	

	private KafkaProducerFactory(){	
	}
	
	/**
	 *  create only one producer for factory 
	 *    
	 * @return
	 */
	public Producer<String, Object> createProducer(){		
		if(null == producer){
			config = new ProducerConfig(producerConfig);
			producer = new Producer<String, Object>(config);
		}		
		return producer;
	}


	public Properties getProducerConfig() {
		return producerConfig;
	}

	public void setProducerConfig(Properties producerConfig) {
		this.producerConfig = producerConfig;
	}


	
}
